home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / editor / auror300.zip / WINCLOCK.AML < prev    next >
Text File  |  1996-07-17  |  2KB  |  76 lines

  1. //--------------------------------------------------------------------
  2. // WINCLOCK.AML
  3. // Edit Window Clock, (C) 1993-1996 by nuText Systems
  4. //
  5. // This macro displays a real-time clock on an edit window. The clock is
  6. // displayed on the horizontal scroll bar, or on the menu bar if the
  7. // horizontal scroll bar is not present.
  8. //
  9. // Winclock updates the clock every 300 milliseconds, when the top
  10. // window is an edit window and no mouse buttons are pressed down.
  11. //
  12. // Usage:
  13. //
  14. // Select this macro from the Macro List (on the Macro menu), or run it
  15. // from the macro picklist <shift f12>. Run this macro again to remove
  16. // the clock.
  17. //--------------------------------------------------------------------
  18.  
  19. include bootpath "define.aml"
  20.  
  21. // clock update delay in milliseconds
  22. constant update_delay = 300
  23. constant timer_id = "wclock"
  24.  
  25. // called when this object is destroyed
  26. event <destroy>
  27.   if prf.slock == getcurrobj then
  28.     destroytimer timer_id
  29.     // flag window to be updated later
  30.     setframe '+'
  31.   end
  32. end
  33.  
  34. // check for a previous install
  35. if object? prf.sclock then
  36.   if (okbox "Winclock already installed. Remove it?") == 'Ok' then
  37.     destroyobject prf.sclock
  38.   end
  39.  
  40. // ensure that edit windows have the appropriate style
  41. elseif not poschar 'hm' _EditStyle then
  42.   msgbox "For Winclock to run, edit windows must have \neither a horizontal scrollbar or a menubar."
  43.  
  44. // install the status clock
  45. else
  46.   setrepeat timer_id update_delay (getcurrobj) "winclock"
  47.   resident ON
  48.   prf.sclock = getcurrobj
  49. end
  50.  
  51.  
  52. // the function handles the 'wclock' timer
  53. function winclock
  54.   if (wintype? "edit") and not button? and (getcoord 'x1') > 15 then
  55.  
  56.     // write directly on the screen
  57.     gotoscreen
  58.  
  59.     x = (getcoord 'r1d') - getvidleft
  60.     y = (getcoord 'b1')
  61.  
  62.     // try the horz scroll bar
  63.     if frame? 'h' then
  64.       writestr (gettime -1)  (getpalette 22 )
  65.                x - 11 (getcoord 'b1') - getvidtop + 2
  66.  
  67.     // try the menu bar/toolbar
  68.     elseif frame? 'm2' then
  69.       writestr '  ' + (gettime -1) + '   ' (getpalette 18)
  70.                x - 12  (getcoord 't1') - getvidtop
  71.     end
  72.  
  73.     gotowindow
  74.   end
  75. end
  76.